package models;

import com.alibaba.fastjson.JSONObject;

/**
 * Created by yangxianming on 2018/10/17.
 * 返回对象
 */
public class ReturnJson {
    public void setResult(int apiStatus, Object result, String errorMsg){
        this.apiStatus = apiStatus;
        this.result = result;
        this.errorMsg = errorMsg;
    }

    public int getApiStatus() {
        return apiStatus;
    }

    public void setApiStatus(int apiStatus) {
        this.apiStatus = apiStatus;
    }

    public Object getResult() {
        return result;
    }

    public void setResult(Object result) {
        this.result = result;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    //0 失败; 1 成功; 默认1为成功
    private int apiStatus = 1;
    //返回具体的数据
    private Object result;

    //如果失败，这里输出失败信息
    private String errorMsg;

    public String toString(){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("apiStatus", apiStatus);
        jsonObject.put("result", result);
        jsonObject.put("errorMsg", errorMsg);
        return jsonObject.toJSONString();
    }
}
